cd "C:\Users\mhoro\Dropbox\CCES20_Minerva\
* cd "C:\Users\horom\Dropbox\CCES20_Minerva\"

set more off
clear all
estimates clear
grstyle init
grstyle set plain
* colorpalette #259797 #db4437
graph set window fontface "Times New Roman"

use aisocietystatereplication.csv, comma replace

* This data has been altered from the original CCES data, with scales reversed and new variables created. The original, unaltered data is also in the replication dataset *

*/ Figure 4 */

*/ Part A */

estimates clear

svyset [iweight=teamweight]
eststo m1: svy: mean pen320
eststo m2: svy: mean pen315
gen pen515=pen315
eststo m3: svy: mean pen515 if (ridesharing==2 | ridesharing==3 | ridesharing==4 | ridesharing==5)

coefplot (m1, mcolor("0 160 138") lcolor("0 160 138") ciopts(lcolor("0 160 138") lwidth(.6))) (m2, mcolor("255 0 0") lcolor("255 0 0") ciopts(lcolor("255 0 0") lwidth(.6))) (m3, mcolor(black) lcolor(black) ciopts(lcolor(black) lwidth(.6))), levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) ylabel(1 "Support for Autonomous Surgery" 2 "Support for Autonomous Vehicles" 3 `" "Support for Autonomous Vehicles" "Among Pre-COVID Rideshare Users" "', grid labsize(medsmall)) legend(off) title("Support", size(medium))

graph save "Graph" "AutonomousSurgeryVehiclesRideshare.gph", replace
graph export "AutonomousSurgeryVehiclesRideshare.png", as(png) name("Graph") replace

*/ Part B */
estimates clear

eststo m1: svy: mean pen322
eststo m2: svy: mean pen317
gen pen517=pen317
eststo m3: svy: mean pen517 if (ridesharing==2 | ridesharing==3 | ridesharing==4 | ridesharing==5)

coefplot (m1, mcolor("0 160 138") lcolor("0 160 138") ciopts(lcolor("0 160 138") lwidth(.6))) (m2, mcolor("255 0 0") lcolor("255 0 0") ciopts(lcolor("255 0 0") lwidth(.6))) (m3, mcolor(black) lcolor(black) ciopts(lcolor(black) lwidth(.6))), levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) ylabel(1 "Willingess to Undergo Autonomous Surgery" 2 "Willingness to Use Autonomous Vehicles" 3 `" "Willingness to Use Autonomous Vehicles" "Among Pre-COVID Rideshare Users" "', grid labsize(medsmall)) legend(off) title("Use", size(medium))

graph save "Graph" "AutonomousSurgeryVehiclesUseRideshare.gph", replace
graph export "AutonomousSurgeryVehiclesUseRideshare.png", as(png) name("Graph") replace

*/ Figure 6 */

eststo m1: regress pen315 gender age white educ pid7 aiindex ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)

eststo m2: regress pen320 gender age white educ pid7 aiindex urbancity [iweight=teamweight], cluster(inputstate)

coefplot (m1, mcolor("255 0 0") lcolor("255 0 0") ciopts(lcolor("255 0 0") lwidth(.6))) (m2, mcolor("0 160 138") lcolor("0 160 138") ciopts(lcolor("0 160 138") lwidth(.6))), xline(0, lcolor(black)) drop(_cons) levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) xtitle(" " "Effect Size (95% Confidence Intervals)", size(medsmall)) ylabel(, grid labsize(small)) legend(lab(2 "Vehicles") lab(4 "Surgery") region(lwidth(none))) order(gender age white educ pid7 aiindex ridesharing drive urbancity)

graph save "Graph" "VehiclesandSurgeryGeneral.gph", replace
graph export "VehiclesandSurgeryGeneral.png", as(png) name("Graph") replace

* Figure 7*

eststo m3: regress pen325 gender age white educ pid7 aiindex milservice urbancity [iweight=teamweight], cluster(inputstate)

eststo m4: regress pen331 gender age white educ pid7 aiindex milservice urbancity [iweight=teamweight], cluster(inputstate)

coefplot (m3, mcolor("255 0 0") lcolor("255 0 0") ciopts(lcolor("255 0 0") lwidth(.6))) (m4, mcolor("0 160 138") lcolor("0 160 138") ciopts(lcolor("0 160 138") lwidth(.6))), xline(0, lcolor(black)) drop(_cons) levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) xtitle(" " "Effect Size (95% Confidence Intervals)", size(medsmall)) ylabel(, grid labsize(small)) legend(lab(2 "Weapons") lab(4 "Cyber Defense") region(lwidth(none))) order(gender age white educ pid7 aiindex ridesharing drive urbancity)

graph save "Graph" "WeaponsandCyberGeneral.gph", replace
graph export "WeaponsandCyberGeneral.png", as(png) name("Graph") replace

*/ Table A1 */

estimates clear

eststo m1: regress pen315 gender age white educ pid7 aiindex ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m2: regress pen315 gender age white educ pid7 aihomework ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m3: regress pen315 gender age white educ pid7 aimusicmovies ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m4: regress pen315 gender age white educ pid7 aiknowledge ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)

esttab m1 m2 m3 m4 using TableA1.tex, replace f t(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels order(aiindex aihomework aimusicmovies aiknowledge gender age white educ pid7 ridesharing drive urbancity) mtitles("\shortstack{Full AI\\Index}" "\shortstack{AI Home\\Work}" "\shortstack{AI Music\\Movies}" "\shortstack{AI\\Knowledge}")

esttab m1 m2 m3 m4 using TableA1.rtf, replace t(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels

*/ Table A2 */

estimates clear

eststo m1: regress pen320 gender age white educ pid7 aiindex ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m2: regress pen320 gender age white educ pid7 aihomework ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m3: regress pen320 gender age white educ pid7 aimusicmovies ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m4: regress pen320 gender age white educ pid7 aiknowledge ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)

esttab m1 m2 m3 m4 using TableA2.tex, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels  order(aiindex aihomework aimusicmovies aiknowledge gender age white educ pid7 ridesharing drive urbancity) mtitles("\shortstack{Full AI\\Index}" "\shortstack{AI Home\\Work}" "\shortstack{AI Music\\Movies}" "\shortstack{AI\\Knowledge}")

esttab m1 m2 m3 m4 using TableA2.rtf, replace se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels

estimates clear

*/ Table A3 */

eststo m1: regress pen325 gender age white educ pid7 aiindex ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m2: regress pen325 gender age white educ pid7 aihomework ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m3: regress pen325 gender age white educ pid7 aimusicmovies ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m4: regress pen325 gender age white educ pid7 aiknowledge ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)

esttab m1 m2 m3 m4 using TableA3.tex, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels  order(aiindex aihomework aimusicmovies aiknowledge gender age white educ pid7 ridesharing drive urbancity) mtitles("\shortstack{Full AI\\Index}" "\shortstack{AI Home\\Work}" "\shortstack{AI Music\\Movies}" "\shortstack{AI\\Knowledge}")

esttab m1 m2 m3 m4 using TableA3.rtf, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels

estimates clear

*/ Table A4 */

eststo m1: regress pen331 gender age white educ pid7 aiindex ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m2: regress pen331 gender age white educ pid7 aihomework ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m3: regress pen331 gender age white educ pid7 aimusicmovies ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)
eststo m4: regress pen331 gender age white educ pid7 aiknowledge ridesharing drive urbancity [iweight=teamweight], cluster(inputstate)

esttab m1 m2 m3 m4 using TableA4.tex, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels  order(aiindex aihomework aimusicmovies aiknowledge gender age white educ pid7 ridesharing drive urbancity) mtitles("\shortstack{Full AI\\Index}" "\shortstack{AI Home\\Work}" "\shortstack{AI Music\\Movies}" "\shortstack{AI\\Knowledge}")

esttab m1 m2 m3 m4 using TableA4.rtf, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels

estimates clear

*/ Table A5 */

eststo m1: regress pen315 gender age white educ gop ridesharing drive urbancity [iweight=teamweight] if aiindex>=3 & aiindex<=5, cluster(inputstate)
eststo m2: regress pen320 gender age white educ gop ridesharing drive urbancity [iweight=teamweight] if aiindex>=3 & aiindex<=5, cluster(inputstate)
eststo m3: regress pen325 gender age white educ gop ridesharing drive urbancity [iweight=teamweight] if aiindex>=3 & aiindex<=5, cluster(inputstate)
eststo m4: regress pen331 gender age white educ gop ridesharing drive urbancity [iweight=teamweight] if aiindex>=3 & aiindex<=5, cluster(inputstate)

esttab m1 m2 m3 m4 using TableA5.tex, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels  order(gender age white educ pid7 ridesharing drive urbancity) mtitles("\shortstack{Autonomous\\Vehicles}" "\shortstack{Autonomous\\Surgery}" "\shortstack{Autonomous\\Weapon Systems}" "\shortstack{Autonomous\\Cyber Defense}")

esttab m1 m2 m3 m4 using TableA5.rtf, replace f se t(3) b(3) scalars("ll Log Likelihood" F) r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) nobaselevels


* Summary Statistics

estimates clear

estpost summarize gender age white educ faminc_new pid7 aiindex aihomework ridesharing drive milservice urbancity coviddeath

esttab using SummaryStatistics2020.rtf, replace label nomtitle nonumber noobs cells("count(fmt(2)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))")
esttab using SummaryStatistics2020.tex, replace f label nomtitle nonumber noobs cells("count(fmt(2)) mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))")

